package com.ml.plugins.ignite;

import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.ignite.Ignite;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.IgniteConfiguration;import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.springdata.repository.config.EnableIgniteRepositories;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
@ImportResource(locations={"classpath:default-config.xml"})
public class IgniteConfig {



	@Autowired
    private IgniteConfiguration igniteCfg;
  
    @Bean
    @ConditionalOnMissingBean
    public Ignite initIgnite() {
      //推荐借助spring bean的方式注入ignite配置信息,只需要将配置xml文件import即可
      //启动类加上注解@ImportResource(locations={"classpath:default-config.xml"})
      Ignite ignite = Ignition.start(igniteCfg);
      ignite.active(true);
      return ignite;
    }
	

	// 记录以及出现的币对
	@Bean
	public ConcurrentHashMap<String, String> igniteCacheKeys() {
		return new ConcurrentHashMap<String, String>();
	}
	
	@Bean
	public ConcurrentHashMap<String, TreeMap<Long, TreeMap<Long, Long>>> hotspot() {
		return new ConcurrentHashMap<String, TreeMap<Long,TreeMap<Long,Long>>>();
	}
}

